﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Resources;
using System.Globalization;
using System.Web;

namespace Besture.Common
{
    public class BaseControl : System.Web.UI.UserControl
    {

        /// <summary>
        /// 编辑页面标识
        /// </summary>
        public bool EditPage = false;

        ///<summary>
        /// Page load event
        ///</summary>
        ///<remarks></remarks>
        protected override void OnLoad(System.EventArgs e)
        {
            //检测编辑编号
            if (!string.IsNullOrEmpty(Query("id")))
            {
                EditPage = true;

            }
            base.OnLoad(e);
        }

        /// <summary>
        /// 分析列表页面
        /// </summary>
        /// <returns></returns>
        protected string ListUrl()
        {
            return HttpContext.Current.Request.Path.ToLower().Replace("set.aspx", "list.aspx");
        }

        /// <summary>
        /// 分析编辑页面
        /// </summary>
        /// <returns></returns>
        protected string SetUrl()
        {
            return HttpContext.Current.Request.Path.ToLower().Replace("list.aspx", "set.aspx");
        }

        /// <summary>
        /// 查询URL参数
        /// </summary>
        /// <param name="param">参数KEY</param>
        /// <returns></returns>
        public string Query(string param)
        {
            if (Request.QueryString[param] == null)
            {
                return string.Empty;
            }
            else
            {
                return Request.QueryString[param];
            }
        }


        /// <summary>
        /// 是否数字
        /// </summary>
        /// <param name="lstr"></param>
        /// <returns></returns>
        public bool IsNumber(string lstr)
        {
            bool isDecimal = false;
            for (int i = 0; i < lstr.Length; i++)
            {
                char ochar = lstr[i];
                if (i == 0 && ochar == '-')
                    continue;
                if (ochar == '.' && !isDecimal)
                {
                    isDecimal = true;
                    continue;
                }
                if (ochar < '0' || ochar > '9')
                {
                    return false;
                }
            }
            return true;
        }


    }


}
